<?php

//------------------------------------------------------------------------------
// Class              : Ctl_Gioithieu
// Modification       :
//------------------------------------------------------------------------------
// Date(yyyy.mm.dd)   Developer                       Action
//------------------------------------------------------------------------------
// 2010.12.05         QuynhTTN                         Created
//------------------------------------------------------------------------------
// 2013.07.25         NguyenNgocManh                   Update
//------------------------------------------------------------------------------

class Ctl_Services extends ControlBase {

    var $modul = "info";

//==========================================================================
// Function    : Ctl_Gioithieu
// Creator     : QuynhTTN 2010.12.05
// Details     : Call the constructor of father class to initial variable
//==========================================================================
    function Ctl_Services() {
// Constructor of father class.
	ControlBase::ControlBase();
    }

//==========================================================================
// Function    : execute
// Argument    :
// ReturnValue :
// Creator     : QuynhTTN 2010.12.05
// Details     : Execute the process depend the given mode,
//               as: Add, Delete, Edit and default is List.
//==========================================================================
    function execute($action = "") {
	global $db;
	global $arrayError, $_POST;
	include_once DIR_MODEL . 'md_services.class.php';
	$objServices = new MD_Services($db);
	$arrayData = array();
// Get back the work you want to do.
	$this->modul = CM_getParameter(MODUL);
	if ($action == "") {
// Get back the action: as: Add, Delete, Edit or List.
	    $action = CM_getParameter(ACTION);
	}

	switch ($action) {
//ManhNN 2013.10.04
//Control Order Start
	    case "List":
	    default :
		$parent_id = CM_getParameter('parent_id');
		if ($parent_id != "") {
		    $listField = "*";
		    $where = "services_type='$parent_id'";
		    $order = " id DESC";
		    $arrayData = $objServices->getByWhere($listField, $where, $order);
		    $where1 = " id = '$parent_id'";
		    $order1 = "";
		    $limit1 = "";
		    $arrayData_Service_type = $objServices->get_services_type_by_Where_1($where1, $order1, $limit1);
		}else{
		    $arrayData = $objServices->getAll("*", " ORDER BY id DESC");
		    $arrayData_Service_type = "";
		}
		include_once DIR_VIEW . 'v_services_list.php';
		V_Services_List($arrayData, $arrayData_Service_type);
		break;
	}

	unset($arrayData);
    }

}

?>